//
//  STMStoreRefundTableViewCell.m
//  StoreManagement
//
//  Created by centling on 16/5/23.
//  Copyright © 2016年 alfred. All rights reserved.
//

#import "STMStoreRefundTableViewCell.h"

@implementation STMStoreRefundTableViewCell


- (void)awakeFromNib {
    [self.auditButton addTarget:self action:@selector(auditButtonClick) forControlEvents:UIControlEventTouchUpInside];
}

- (void)setCellData:(STMStoreRefundDataArray *)cellData {
    self.auditRefundId = cellData.refund_id;
    self.orderSNLabel.text = [NSString stringWithFormat:@"编号:%@", cellData.order_sn];
    self.refundMoneyLabel.text = cellData.refund_amount;
    self.reasonLabel.text = [NSString stringWithFormat:@"原因：%@", cellData.reason_info];
    if (self.forGoodsReturn) {
        self.buyerNameLabel.text = [NSString stringWithFormat:@"退货人：%@", cellData.buyer_name];
        self.refundDecriptionLabel.text = [NSString stringWithFormat:@"退货说明：%@", cellData.buyer_message];
    } else {
        self.buyerNameLabel.text = [NSString stringWithFormat:@"退款人：%@", cellData.buyer_name];
        self.refundDecriptionLabel.text = [NSString stringWithFormat:@"退款说明：%@", cellData.buyer_message];
    }
    
    [self.goodsImageView sd_setImageWithURL:[NSURL URLWithString:cellData.goods_image] placeholderImage:nil];
    self.goodsNameLabel.text = cellData.goods_name;
    self.goodsPriceLabel.text = [NSString stringWithFormat:@"价格：¥%@", cellData.goods_price];
    self.replyLabel.text = [NSString stringWithFormat:@"回复：%@", cellData.seller_message];
    self.dateLabel.text = [GlobalUtil setUpTime:cellData.add_time];
    
    if ([self.state isEqualToString:@"1"]) {
        self.replyLabel.hidden = YES;
        self.dateLabelToReplyLabel.constant = -16;
        self.auditBtnToReplyLabel.constant = -16;
    } else {
        self.auditButton.hidden = YES;
    }
}

- (void)auditButtonClick {
    if (self.forGoodsReturn) {
        if (_refundCellBlock) {
            _refundCellBlock(self.auditRefundId);
        }
    } else {
        if (_refundCellBlock) {
            _refundCellBlock(self.auditRefundId);
        }
    }
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
